package cn.iocoder.yudao.module.def.dal.mysql.attachment;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.def.dal.dataobject.attachment.AttachmentDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.def.controller.admin.attachment.vo.*;

/**
 * 附件 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface AttachmentMapper extends BaseMapperX<AttachmentDO> {

    default PageResult<AttachmentDO> selectPage(AttachmentPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<AttachmentDO>()
                .eqIfPresent(AttachmentDO::getCategory, reqVO.getCategory())
                .eqIfPresent(AttachmentDO::getAdminId, reqVO.getAdminId())
                .eqIfPresent(AttachmentDO::getUserId, reqVO.getUserId())
                .eqIfPresent(AttachmentDO::getUrl, reqVO.getUrl())
                .eqIfPresent(AttachmentDO::getImagewidth, reqVO.getImagewidth())
                .eqIfPresent(AttachmentDO::getImageheight, reqVO.getImageheight())
                .eqIfPresent(AttachmentDO::getImagetype, reqVO.getImagetype())
                .eqIfPresent(AttachmentDO::getImageframes, reqVO.getImageframes())
                .likeIfPresent(AttachmentDO::getFilename, reqVO.getFilename())
                .eqIfPresent(AttachmentDO::getFilesize, reqVO.getFilesize())
                .eqIfPresent(AttachmentDO::getMimetype, reqVO.getMimetype())
                .eqIfPresent(AttachmentDO::getExtparam, reqVO.getExtparam())
                .betweenIfPresent(AttachmentDO::getCreatetime, reqVO.getCreatetime())
                .betweenIfPresent(AttachmentDO::getUpdatetime, reqVO.getUpdatetime())
                .betweenIfPresent(AttachmentDO::getUploadtime, reqVO.getUploadtime())
                .eqIfPresent(AttachmentDO::getStorage, reqVO.getStorage())
                .eqIfPresent(AttachmentDO::getSha1, reqVO.getSha1())
                .orderByDesc(AttachmentDO::getId));
    }

}